//
//  WXDetailViewController.m
//  Big Show
//
//  Created by dlios on 15-5-13.
//  Copyright (c) 2015年 Big_Q. All rights reserved.
//

#import "WXDetailViewController.h"
#import "WXDetailCollectionViewCell.h"

@interface WXDetailViewController ()<UICollectionViewDataSource,  UICollectionViewDelegate>
@property (nonatomic, retain) UICollectionView *collectionView;
@end

@implementation WXDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self creat];
}
-(void)creat
{
    // 创建collectiView
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
    _collectionView.backgroundColor = [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1];
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    [self.view addSubview:_collectionView];
    [_collectionView release];
    [flowLayout release];
#warning collectionView创建时必须先注册一个cell
    [_collectionView registerClass:[WXDetailCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
}
#pragma mark - 必须实现的协议方法1
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 12;
}

#pragma mark - 必须实现的协议方法2
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    WXDetailCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
//    UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(20, 15, 150, 120)];
//    image1.backgroundColor = [UIColor greenColor];
    
//    UIImageView *image2 = [[UIImageView alloc]initWithFrame:CGRectMake(190, 15, 150, 120)];
//    image2.backgroundColor = [UIColor greenColor];
//    [cell.contentView addSubview:image1];
//    [cell.contentView addSubview:image2];
//    [image1 release];
//    [image2 release];
//    
//    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 360, 30)];
//    label.backgroundColor = [UIColor redColor];
//    [cell.contentView addSubview:label];
//    [label release];
    return cell;
}

//cell的尺寸
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(365, 150);
}

// 外边距
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return  UIEdgeInsetsMake(10, 0, 10, 5);
}
// 内面行距
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 20;
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
